/*
 ***** BEGIN LICENSE BLOCK *****
 * Version: MPL 1.1

 * The contents of this file are subject to the Mozilla Public License Version 
 * 1.1 (the "License"); you may not use this file except in compliance with 
 * the License. You may obtain a copy of the License at 
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * The Original Code is Blazing Games Inc. (Billy D. Spelchan) code.
 *
 * The Initial Developer of the Original Code is
 * Blazing Games Inc.
 * Portions created by the Initial Developer are Copyright (C) 1999, 2003, 2005-2006
 * the Initial Developer. All Rights Reserved.
 * 
 * Contributor(s):
 *
 ***** END LICENSE BLOCK *****
 */
package com.blazinggames.holeman;

import java.awt.*;
import java.awt.event.*;
//import java.util.*;

public class LevelList
extends Panel {
// *** CONSTANTS ***
  Button btnCaption[] = new Button[8];
  Panel pnlActions[] = new Panel[8];
  Button btnEdit[] = new Button[8];
  Button btnTest[] = new Button[8];
  Button btnPlay[] = new Button[8];
  Label lblBlank;
  Label lblCopyright;
  
// *** VARIABLES ***

// *** METHODS - CONSTRUCTOR ***
	LevelList(ActionListener al) {
    int cntr;

    for (cntr = 0; cntr < 8; ++cntr) {
      btnCaption[cntr] = new Button("Caption");
      btnCaption[cntr].setActionCommand("Capt" + cntr);
      btnCaption[cntr].addActionListener(al);
      btnEdit[cntr] = new Button("Edit");
      btnEdit[cntr].setActionCommand("Edit" + cntr);
      btnEdit[cntr].addActionListener(al);
      btnTest[cntr] = new Button("Test");
      btnTest[cntr].setActionCommand("Test" + cntr);
      btnTest[cntr].addActionListener(al);
      btnPlay[cntr] = new Button("Play");
      btnPlay[cntr].setActionCommand("Play" + cntr);
      btnPlay[cntr].addActionListener(al);
      pnlActions[cntr] = new Panel(new GridLayout(1,3,5, 0));
      pnlActions[cntr].add(btnEdit[cntr]);
      pnlActions[cntr].add(btnTest[cntr]);
      pnlActions[cntr].add(btnPlay[cntr]);
    }
    lblBlank = new Label("Mr. Holeman");
    lblCopyright = new Label("Copyright " + ((char)169) + " 1999,2003,2005 Blazing Games Inc.");

		// set up the layout
		setLayout(new GridLayout(9,2, 10,10));
    for (cntr = 0; cntr < 8; ++cntr) {
      add(btnCaption[cntr]);
      add(pnlActions[cntr]);
    }
    add(lblBlank);
    add(lblCopyright);
	}

  public void refreshList(Map m) {
    for (int cntr = 0; cntr < 8; ++cntr) {
      btnCaption[cntr].setLabel(m.sCaption[cntr]);
      if (m.bLock[cntr]) {
        btnEdit[cntr].setEnabled(false);
        btnTest[cntr].setEnabled(false);
      }
      else {
        btnEdit[cntr].setEnabled(true);
        btnTest[cntr].setEnabled(true);
      }
    }
  }
}
